Tobias Belgabor contributes filter for selection points based on DOP.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 23 Jul 2005 05:23:13 +0000 (05:23 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 23 Jul 2005 05:23:13 +0000 (05:23 +0000)
gpsbabel/Makefile
gpsbabel/README
gpsbabel/dopfilt.c [new file with mode: 0644]
gpsbabel/filter_vecs.c
gpsbabel/style/openoffice.style

index 87bb71a9a7ede6ca4dd0971ca1df337a1548c3fb..b36a46c41926bcf35f51c76d89f12a013ca145dd 100644 (file)
@@ -38,7 +38,7 @@ FMTS=magproto.o gpx.o geo.o mapsend.o mapsource.o garmin_tables.o \
        vcf.o overlay.o kml.o google.o lowranceusr.o an1.o tomtom.o \
        tef_xml.o maggeo.o pathaway.o vitosmt.o gdb.o bcr.o
 
-FILTERS=position.o duplicate.o arcdist.o polygon.o smplrout.o reverse_route.o sort.o stackfilter.o trackfilter.o
+FILTERS=position.o duplicate.o arcdist.o polygon.o smplrout.o reverse_route.o sort.o stackfilter.o trackfilter.o dopfilt.o
 
 OSJEEPS=jeeps/gpslibusb.o
 JEEPS=jeeps/gpsapp.o jeeps/gpscom.o \
index e50d9331fed84b5c6197c16c721291d3a6b56b55..ba814f9d76d2e068f3dfbed75ac7992f71710c0e 100644 (file)
@@ -464,6 +464,12 @@ THE FORMATS
         GpsDrive way.txt file format. A space seperated format file. Tested
         against GpsDrive v 1.30 found @ http://www.kraftvoll.at/software.
         Contributed by Alan Curry.
+       
+    GPSDRIVETRACK
+    
+        Format used by GpsDrive to save tracks. Like GPSDRIVE a space
+       seperated format file. See above for a link to GpsDrive.
+       Contributed by Tobias Minich.
 
     Geocaching DB
 
@@ -905,7 +911,15 @@ THE FORMATS
                 -i gpx -f in.gpx
                 -o bcr,index=1,name="From A to B",radius=6371012 \
                 -F a_to_b.bcr
-         
+       
+    OPENOFFICE
+       Tab seperated export-all (except geocahing data) file format. 
+       Intended to serve as source for number-processing applications
+       like OpenOffice, Ploticus and others. Tab was chosen as delimiter
+       because it is a) supported by both OpenOffice and Ploticus and
+       b) is not ',', so you can use 'sed -i "s/./,/g" <x>.csv' to adapt it to
+       locales where ',' is used as decimal seperator.
+       Contributed by Tobias Minich.
 
 DATA FILTERS
 
@@ -1251,3 +1265,31 @@ DATA FILTERS
                        -i gpx -f in.gpx \ 
                        -x track,pack,split=4h,title="LOG # %c" \ 
                        -o gpx -F out.gpx
+
+    DOP
+
+        This filter 'fixes' gps data by discarding points with a hdop
+        and/or vdop over a set limit. If you give both the hdop and a
+        vdop options, by default points that exceed EITHER are discarded
+        (OR). This filter processes waypoints, tracks, and routes.
+
+        HDOP (float)
+
+            Points with a hdop exceeding the given value are discarded.
+
+        VDOP (float)
+
+            Points with a vdop exceeding the given value are discarded.
+
+        HDOPANDVDOP
+
+            Only useful if both hdop and vdop are given. Now logical AND
+            is used, i.e. only points exceeding both given values are
+            discarded.
+
+            Example: gpsbabel \ 
+               -i gpx -f in.gpx \
+               -x fix,hdop=10,vdop=20,hdopandvdop \ 
+               -o gpx -F out.gpx
+
+        Contributed by Tobias Minich.
diff --git a/gpsbabel/dopfilt.c b/gpsbabel/dopfilt.c
new file mode 100644 (file)
index 0000000..a459468
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+    Suppress points based on high Degree of Precision (DOP) values.
+
+    Copyright (C) 2005 Robert Lipe, robertlipe@usa.net
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
+#include <stdio.h>
+#include "defs.h"
+
+extern queue waypt_head;
+
+static char *hdopopt = NULL;
+static char *vdopopt = NULL;
+static char *andopt = NULL;
+static double hdopf;
+static double vdopf;
+
+static
+arglist_t fix_args[] = {
+       {"hdop", &hdopopt, "Suppress waypoints with higher hdop",
+               "-1.0", ARGTYPE_BEGIN_REQ | ARGTYPE_FLOAT},
+       {"vdop", &vdopopt, "Suppress waypoints with higher vdop",
+               "-1.0", ARGTYPE_END_REQ | ARGTYPE_FLOAT},
+       {"hdopandvdop", &andopt, "Link hdop and vdop supression with AND",
+               NULL, ARGTYPE_BOOL},
+       {0, 0, 0, 0, 0}
+};
+
+static void
+fix_process_track(const route_head *trk)
+{
+       waypoint * waypointp;
+       queue *elem, *tmp;
+       
+       QUEUE_FOR_EACH((queue *)&trk->waypoint_list, elem, tmp) {
+               
+               int del = 0;
+               int delh = 0;
+               int delv = 0;
+
+               waypointp = (waypoint *)elem;
+               
+               if ((hdopf >= 0.0) && (waypointp->hdop > hdopf))
+                       delh = 1;
+               if ((vdopf >= 0.0) && (waypointp->vdop > vdopf))
+                       delv = 1;
+               
+               if (andopt)
+                       del = delh && delv;
+               else
+                       del = delh || delv;
+
+               if (del) {
+                       waypt_del(waypointp);
+                       waypt_free(waypointp);
+               }
+
+       }
+}
+
+void
+fix_process(void)
+{
+       waypoint * waypointp;
+
+       int tc = track_count();
+       int rc = route_count();
+       
+       queue *elem, *tmp;
+       extern queue waypt_head;
+       
+       // Filter waypoints
+
+       QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
+               
+               int del = 0;
+               int delh = 0;
+               int delv = 0;
+
+               waypointp = (waypoint *)elem;
+               
+               if ((hdopf >= 0.0) && (waypointp->hdop > hdopf))
+                       delh = 1;
+               if ((vdopf >= 0.0) && (waypointp->vdop > vdopf))
+                       delv = 1;
+               
+               if (andopt)
+                       del = delh && delv;
+               else
+                       del = delh || delv;
+
+               if (del) {
+                       waypt_del(waypointp);
+                       waypt_free(waypointp);
+               }
+
+       }
+       
+       // Filter tracks
+       if (tc > 0)
+           track_disp_all(fix_process_track, NULL, NULL);
+       
+       // And routes
+       if (rc > 0)
+           route_disp_all(fix_process_track, NULL, NULL);
+       
+}
+
+void
+fix_init(const char *args) 
+{
+       if (hdopopt)
+               hdopf = atof(hdopopt);
+       else
+               hdopf = -1.0;
+       if (vdopopt)
+               vdopf = atof(vdopopt);
+       else
+               vdopf = -1.0;
+}
+
+void
+fix_deinit(void) 
+{
+}
+
+filter_vecs_t fix_vecs = {
+       fix_init,
+       fix_process,
+       fix_deinit,
+       NULL,
+       fix_args
+};
index 646f486e51ebf5ba9fad1487e1c51690a53f8fd3..8531911d9e039aa30ddc3fd7470d98a10752ddb0 100644 (file)
@@ -38,6 +38,7 @@ extern filter_vecs_t reverse_route_vecs;
 extern filter_vecs_t sort_vecs;
 extern filter_vecs_t stackfilt_vecs;
 extern filter_vecs_t trackfilter_vecs;
+extern filter_vecs_t fix_vecs;
 
 static
 fl_vecs_t filter_vec_list[] = {
@@ -91,6 +92,11 @@ fl_vecs_t filter_vec_list[] = {
                "track",
                "Manipulate track lists"
        },
+       {
+               &fix_vecs,
+               "dop",
+               "Remove unreliable points with high hdop or vdop."
+       },
         {
                NULL,
                NULL,
index b39a179cf8ddc6c2ad2c298ea6f8339523f4c01e..ea42b7f9d17b4037906db28947d4465da31902ae 100644 (file)
@@ -6,14 +6,13 @@
 #
 #
 
-DESCRIPTION            Custom "Everything" Style
+DESCRIPTION            Tab delimitered csv useful for OpenOffice, Ploticus etc.
 
 # FILE LAYOUT DEFINITIIONS:
 #
 FIELD_DELIMITER                TAB
 RECORD_DELIMITER       NEWLINE
 BADCHARS               TAB
-FORMAT_TYPE            INTERNAL
 
 #
 # HEADER STUFF: